home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Miscellaneous things - 2 *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen. All *)
- (* rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- UNIT BBMISC2;
-
- INTERFACE
-
- USES
- bbdummy;
-
- PROCEDURE send_msg_header (type_head : INTEGER);
- PROCEDURE cannot_do_this (mess_number : BYTE);
-
- PROCEDURE msg_action_check(this_msg : msg_index_ptr;
- VAR last_msg_action : action_msg_ptr);
-
- FUNCTION bbs_busy : BOOLEAN;
- FUNCTION get_option_string(VAR in_s : STRING) : str15;
- FUNCTION find_mail(mail_type : CHAR) : BOOLEAN;
-
- IMPLEMENTATION
-
- USES
- bbmdata,
- bbmess,
- bbmf,
- bbsearch,
- bbstr,
- bbtrace;
-
- {$UNDEF DEBUG_ACT}
-
- (*===========================================================================*)
- (* Send the message header *)
- (*===========================================================================*)
-
- PROCEDURE send_msg_header(type_head : INTEGER);
-
- BEGIN;
-
- IF type_head < 0 THEN
- type_head := active_tcb^.uid_data.user_fmt;
-
- CASE type_head OF
- 1: send_message(message_msg_head1);
- 2: send_message(message_msg_head2);
- 3: send_message(message_msg_head3);
- 4: send_message(message_msg_head4);
- ELSE
- send_message(message_msg_head0);
- END;
-
- END;
-
- (*===========================================================================*)
- (* Routine called if something is busy so we can't do anything *)
- (*===========================================================================*)
-
- PROCEDURE cannot_do_this(mess_number : BYTE);
-
- BEGIN;
-
- send_message(mess_number);
-
- IF active_tcb^.tcb_type <> th_fwd_control THEN EXIT;
-
- wakeup_did_something := FALSE;
-
- END;
-
- (*===========================================================================*)
- (* Routine called to see if a message is on the action list *)
- (*===========================================================================*)
-
- PROCEDURE msg_action_check(this_msg : msg_index_ptr;
- VAR last_msg_action : action_msg_ptr);
-
- VAR
- b : BOOLEAN;
- local_msg_action : action_msg_ptr;
-
- BEGIN;
-
- IF last_msg_action = NIL THEN
- local_msg_action := first_msg_action
- ELSE
- local_msg_action := last_msg_action^.next_action;
-
- {$IFDEF DEBUG_ACT}
- trace_data('MACheckS', local_msg_action^.action_type,
- this_msg, local_msg_action^.action_info);
- {$ENDIF}
-
- WHILE local_msg_action <> NIL DO
- BEGIN;
-
- IF local_msg_action^.action_srch = NIL THEN
- b := search_test(local_msg_action^.action_info, this_msg)
- ELSE
- b := search_test_block(local_msg_action^.action_srch, this_msg);
-
- IF b THEN
- BEGIN;
- last_msg_action := local_msg_action;
- EXIT;
- END;
-
- local_msg_action := local_msg_action^.next_action;
-
- {$IFDEF DEBUG_ACT}
- trace_data('MACheckL', local_msg_action^.action_type,
- this_msg, local_msg_action^.action_info);
- {$ENDIF}
-
- END;
-
- {$IFDEF DEBUG_ACT}
- trace_data('MACheckE', local_msg_action^.action_type,
- this_msg, local_msg_action^.action_info);
- {$ENDIF}
-
- last_msg_action := NIL;
-
- END;
-
- (*===========================================================================*)
- (* See if anyone else is on.. *)
- (*===========================================================================*)
-
- FUNCTION bbs_busy : BOOLEAN;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Assume we are failing *)
- (*-----------------------------------------------------------------------*)
-
- bbs_busy := TRUE;
-
- (*-----------------------------------------------------------------------*)
- (* Fail if forwarding is busy *)
- (*-----------------------------------------------------------------------*)
-
- IF fwd_out_busy AND (active_tcb^.tcb_type <> th_fwd_control) THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Fail if operator is busy *)
- (*-----------------------------------------------------------------------*)
-
- IF op_busy AND (active_tcb^.tcb_type <> th_operator) THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Fail if local operator or WAKEUP and someone else is on *)
- (*-----------------------------------------------------------------------*)
-
- IF (active_tcb^.tcb_type <= th_fwd_control)
- AND (alive_tcb_count <> overhead_tcb_count) THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Fail if remote SYSOP and anyone else is on *)
- (*-----------------------------------------------------------------------*)
-
- IF (active_tcb^.tcb_number > overhead_tcb_count)
- AND (alive_tcb_count <> (overhead_tcb_count + 1)) THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Everything else works *)
- (*-----------------------------------------------------------------------*)
-
- bbs_busy := FALSE;
-
- END;
-
- (*===========================================================================*)
- (* Get the option block from a string and remove the block *)
- (*===========================================================================*)
-
- FUNCTION get_option_string(VAR in_s : STRING) : str15;
-
- VAR
- i : BYTE;
- out_s : str15;
-
- BEGIN;
-
- out_s := subword(@in_s, 2, 1);
-
- IF (LENGTH(out_s) = 0)
- OR (out_s[1] <> '[')
- OR (out_s[LENGTH(out_s)] <> ']') THEN
- BEGIN;
- get_option_string := '';
- EXIT;
- END;
-
- get_option_string := out_s;
-
- in_s := SUBWORD(@in_s, 1, 1) + ' ' + SUBWORD(@in_s, 3, 0);
-
- END;
-
- (*===========================================================================*)
- (* This checks to see if there is a certain type of mail *)
- (*===========================================================================*)
-
- FUNCTION find_mail(mail_type : CHAR) : BOOLEAN;
-
- VAR
- search_block : search_block_type;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Set up for search *)
- (*-----------------------------------------------------------------------*)
-
- FILLCHAR(search_block, SIZEOF(search_block), #0);
-
-
- search_block.search_ascend := TRUE;
- search_block.search_type := mail_type;
- search_block.search_str := active_tcb^.uid_data.user_id;
- search_block.search_last := NIL;
-
- (*-----------------------------------------------------------------------*)
- (* Search for the messages. *)
- (*-----------------------------------------------------------------------*)
-
- search_msg(@search_block);
-
- find_mail := search_block.search_last <> NIL;
-
- END;
-
- END.